﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cinser.Common.Wpf.Controls
{

    public  class WinProgressPlus
    {
        Cinser.Common.Wpf.Controls.WinProgress win;
        private string subtitle = string.Empty;
        private string currentOperation = string.Empty;
        private double currentPercent = 0;
        private Cinser.Common.Wpf.Controls.ProgressList contentList;

        public Cinser.Common.Wpf.Controls.ProgressList ContentList
        {
            get
            {
                if (contentList == null)
                    contentList = new ProgressList();
                return contentList;
            }
            set { contentList = value; }
        }

        public double CurrentPercent
        {
            get { return currentPercent; }
            set { currentPercent = value; }
        }

        public string CurrentOperation
        {
            get { return currentOperation; }
            set { currentOperation = value; }
        }

        public string Subtitle
        {
            get { return subtitle; }
            set { subtitle = value; }
        }

        public WinProgressPlus(string title,NoReturnHandler doWork)
        {
             win = new Cinser.Common.Wpf.Controls.WinProgress(
                new ReturnStrHandler(GetSubtitle),
                new ReturnStrHandler(GetCurrentOperation),
                new ReturnDoubleHandler(GetCurrentPercent),
                ContentList, 
                doWork
                );
            win.Title = title;
        }
        
        public void Show()
        {
            win.Show();
        }

        private string GetSubtitle()
        {
            return this.Subtitle;
        }

        private string GetCurrentOperation()
        {
            return this.CurrentOperation;
        }

        private double GetCurrentPercent()
        {
            return this.CurrentPercent;
        }
    }
}
